<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>库存查询</title>
<meta name="decorator" content="default" />
<style type="text/css">
.ui-grid-a>.ui-block-a {
width: 30%;
}

.ui-grid-a>.ui-block-b {
width: 70%;
}

</style>
</head>
<body>
	<div class="container">
		<div class="icon-buttons">
			<a data-role="button" data-inline="true" data-icon="back"
				data-iconpos="notext" href="${ctx}">返回</a>
		</div>
		<form:form id="searchForm" modelAttribute="inventoryQuery"
			action="${ctx}/inventory/query" method="post">
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
			<input id="pageSize" name="pageSize" type="hidden"
				value="${page.pageSize}" />
			<label>产品名称</label>
			<form:input id="keyWord" name="keyWord" type="search"
				path="productName" value="${inventoryQuery.productName}"></form:input>
			<fieldset data-role="controlgroup" data-type="horizontal" data-inline="true">
		        <input type="radio" name="includingZero" id="radio-choice-a" value="0" ${inventoryQuery.includingZero == 'true' ? 'checked' : ''}>
		        <label for="radio-choice-a">含空库存</label>
		        <input type="radio" name="includingZero" id="radio-choice-b" value="1" ${empty inventoryQuery.includingZero || inventoryQuery.includingZero == 'false' ? 'checked' : ''}>
		        <label for="radio-choice-b">不含空库存</label>
			</fieldset>
		&nbsp;<input data-inline="true" type="submit" value="查询" />
		</form:form>
		<tags:message content="${message}" />
		<table id="contentTable" data-role="table"
			class="ui-responsive table-stroke">
			<thead>
				<tr>
					<th colspan="6" style="text-align:center;">库存明细</th>
				</tr>
				<tr>
					<th>产品渠道</th>
					<th>产品分类</th>
					<th>产品名称</th>
					<th>规格</th>
					<th>零售价</th>
					<th>数量</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${page.list}" var="storeProduct">
					<c:set var="issystem" value="${ storeProduct.product_type==0}"></c:set>
					<c:if test="${issystem }">
						<tr name="${storeProduct.product.name}" type="系统产品"
							category="${storeProduct.product.productCategory.name}"
							spec="${storeProduct.product.spec}"
							price="${storeProduct.product.retail_price}"
							amount="${storeProduct.amount}">
							<td>系统产品</td>
							<td></td>
							<td>${storeProduct.product.name}</td>
							<td>${storeProduct.product.spec}</td>
							<td>${storeProduct.product.retail_price}</td>
							<td>${storeProduct.amount}</td>
						</tr>
					</c:if>
					<c:if test="${!issystem }">
						<tr name="${storeProduct.storeSelfProduct.name}" type="店面自营"
							category="${storeProduct.storeSelfProduct.storeSelfProductCategory.name}"
							spec="${storeProduct.storeSelfProduct.spec}"
							price="${storeProduct.storeSelfProduct.retail_price}"
							amount="${storeProduct.amount}">
							<td>店面自营</td>
							<td>
								${storeProduct.storeSelfProduct.storeSelfProductCategory.name}</td>
							<td>${storeProduct.storeSelfProduct.name}</td>
							<td>${storeProduct.storeSelfProduct.spec}</td>
							<td>${storeProduct.storeSelfProduct.retail_price}</td>
							<td>${storeProduct.amount}</td>
						</tr>

					</c:if>
				</c:forEach>
			</tbody>
		</table>
		<div class="pagination">${page}</div>
	</div>
	<!-- 产品选择 -->
	<div data-role="popup" id="product-detail-dialog">
		<div data-role="header">
			<h1>产品明细</h1>
		</div>
		<div data-role="content"
			style="overflow:scroll;height:20em;width: 25em" id="productdetail">
			<div class="ui-grid-a">
				<div class="ui-block-a">
					<label for="name">产品名称:</label>
				</div>
				<div class="ui-block-b">
					<strong><span id="name"></span> </strong>
				</div>
			</div>
			<div class="ui-grid-a">
				<div class="ui-block-a">
					<label>产品渠道: </label>
				</div>
				<div class="ui-block-b">
					<strong><span id="type"></span> </strong>
				</div>
			</div>
			<div class="ui-grid-a">
				<div class="ui-block-a">
					<label>产品分类: </label>
				</div>
				<div class="ui-block-b">
					<strong><span id="category"></span> </strong>
				</div>
			</div>
			<div class="ui-grid-a">
				<div class="ui-block-a">
					<label>规格: </label>
				</div>
				<div class="ui-block-b">
					<strong><span id="spec"></span> </strong>
				</div>
			</div>
			<div class="ui-grid-a">
				<div class="ui-block-a">
					<label>零售价: </label>
				</div>
				<div class="ui-block-b">
					<strong><span id="price"></span> </strong>
				</div>
			</div>
			 <div class="ui-grid-a">
				<div class="ui-block-a">
					<label>数量: </label>
				</div>
				<div class="ui-block-b">
					<strong><span id="amount"></span> </strong>
				</div>
			</div>
		</div>
		<!-- /content -->
		<div data-role="footer">
			<a href="#" data-rel="back" data-role="button" data-inline="true"
				data-icon="back">关闭</a>
		</div>
	</div>
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#contentTable tbody tr").click(
						function() {
							$("#contentTable tbody tr").removeClass(
									"select_active");
							$(this).addClass("select_active");
							var item = $(this);
							$("#product-detail-dialog span#name").text(
									item.attr("name"));
							$("#product-detail-dialog span#category").text(
									item.attr("category"));
							$("#product-detail-dialog span#type").text(
									item.attr("type"));
							$("#product-detail-dialog span#price").text(
									item.attr("price"));
							$("#product-detail-dialog span#amount").text(
									item.attr("amount"));
							$("#product-detail-dialog span#spec").text(
									item.attr("spec"));
							$("#product-detail-dialog").popup("open");
						});
			});
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
</script>

</body>
</html>
